package za.org.jcicada.genss.sensor.impl;

import java.net.URISyntaxException;
import java.util.Observable;

import za.org.jcicada.genss.sensor.ISensorValue;
import za.org.jcicada.genss.sensor.SensorURN;

public class StrategyPeriodicEvent extends StrategyPeriodic {

	private static final long serialVersionUID = 1L;
	private Object lastValue;

	public StrategyPeriodicEvent(SensorURN sensorURN, int period_ms) {
		super(sensorURN, period_ms);
	}

	public StrategyPeriodicEvent(String[] args) throws URISyntaxException {
		super(args);
	}

	/**
	 * Default update handler which does nothing when a sensor informs it of a
	 * change.
	 */
	@Override
	protected void updateValue(Observable o, ISensorValue value) {
		if (!value.getValue().equals(lastValue)) {
			setNextTime(value.getTime() + getPeriod_ms());
			lastValue = value.getValue();
			notifySample(value);
		}
	}

}
